﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace 语音朗读机器人
{
    public partial class BOTAdmin : Form
    {
        public BOTAdmin()
        {
            InitializeComponent();
        }
        private string thispath = "";
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            plugin.IsNoName = this.checkBox1.Checked;
        }

        private void BOTAdmin_Load(object sender, EventArgs e)
        {
            thispath = AppDomain.CurrentDomain.BaseDirectory;
            IniHelper _ini = new IniHelper();
            plugin.IsNoName = _ini.ReadIniKeys("user", "IsNoName", thispath + "conf.ini")=="1"?true:false;
            plugin.IsNogift = _ini.ReadIniKeys("user", "IsNogift", thispath + "conf.ini") == "1" ? true : false;
            this.checkBox1.Checked = plugin.IsNoName;
            this.checkBox2.Checked = plugin.IsNogift;
            ModeComboBox1.SelectedIndex = plugin._tts.mode;
            comboBox1.SelectedIndex = comboBox1.Items.IndexOf(plugin.etts.NowSpeaker);
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            plugin.IsNogift = this.checkBox2.Checked;
        }

        private void BOTAdmin_FormClosing(object sender, FormClosingEventArgs e)
        {
            IniHelper _ini = new IniHelper();
            _ini.WriteIniKeys("user", "IsNoName", plugin.IsNoName == true ? "1" : "0", thispath + "conf.ini") ;
            _ini.WriteIniKeys("user", "IsNogift", plugin.IsNogift == true ? "1" : "0", thispath + "conf.ini");
        }

        private void ModeComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
             plugin._tts.mode= ModeComboBox1.SelectedIndex;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            plugin.etts.ChangeSpeaker(comboBox1.Text);
        }
    }
    
}
